package com.shycloud.mido.music.service.impl;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.shycloud.mido.music.domain.MisUserMusic;
import com.shycloud.mido.music.mapper.MisUserMusicMapper;
import com.shycloud.mido.music.service.MisUserMusicService;
import com.shycloud.mido.music.vo.MisMusicVO;
import lombok.AllArgsConstructor;
import org.springframework.stereotype.Service;

@Service
@AllArgsConstructor
public class MisUserMusicServiceImpl extends ServiceImpl<MisUserMusicMapper, MisUserMusic> implements MisUserMusicService {

	/** 收藏模块 mapper */
	private MisUserMusicMapper userMusicMapper;

	/**
	 * 分页获取【我喜欢】列表
	 *
	 * @param page
	 * @param userId
	 * @param type
	 * @return com.baomidou.mybatisplus.core.metadata.IPage<com.shycloud.mido.music.domain.MisMusic>
	 * @author nianhua.jiang
	 * @date 2020/6/13 14:56
	 */
	@Override
	public IPage<MisMusicVO> getUserMusic(Page page, String userId, String type) {
		return userMusicMapper.getUserMusic(page, userId, type);
	}

	/**
	 * 获取用户此月下载 MP3的数量
	 *
	 * @param memberId
	 * @return int
	 * @author nianhua.jiang
	 * @date 2020/9/14 18:12
	 **/
	@Override
	public int getDownloadMp3Count(String memberId) {
		return userMusicMapper.getDownloadMp3Count(memberId);
	}

	@Override
	public Integer getUserMusicCount(String memberId) {
		return userMusicMapper.getUserMusicCount(memberId, 1);
	}
}
